package base.day22.file;

import java.io.File;
import java.io.IOException;

public class MyFile2 {
    public static void main(String[] args) throws IOException {
        File f1=new File("E:\\text\\java text\\a.txt");
        //createnewfile 创建一个新的空文件
        boolean result = f1.createNewFile();
        System.out.println(result);

        //mkdir 创建一个单级文件夹
        File f2=new File("E:\\text\\java text\\aaa");
        boolean mkdir = f2.mkdir();
        System.out.println(mkdir);

        //mkdirs 创建一个多级文件夹
        File f3=new File("E:\\text\\java text\\aaa\\bbb\\ccc");
        boolean mkdirs = f3.mkdirs();
        System.out.println(mkdirs);

        //delete 删除文件
        File f4=new File("E:\\text\\java text\\a.txt");
        boolean delete = f4.delete();
        System.out.println(delete);

        //isFile 测试是否是文件
        File f5=new File("E:\\text\\java text\\test1.txt");
        boolean isfile = f5.isFile();
        System.out.println(isfile);
        //isdirectory 判断是否为文件夹
        boolean isdirectory = f5.isDirectory();
        System.out.println(isdirectory);
        //exists 测试file是否存在
        boolean isexists = f5.exists();
        System.out.println(isexists);
        //getname返回最后一级文件或目录的名称
        String name = f5.getName();
        System.out.println(name);


    }
}
